package com.helei.consumerListener;

import org.apache.rocketmq.common.message.MessageExt;
import org.apache.rocketmq.spring.annotation.ConsumeMode;
import org.apache.rocketmq.spring.annotation.MessageModel;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Component;

@Component
@RocketMQMessageListener(topic = "sync-topic-boot", consumerGroup = "group-sync",
        consumeMode = ConsumeMode.CONCURRENTLY,
        maxReconsumeTimes = 3,messageModel = MessageModel.BROADCASTING)
public class ConsumerListenerRocketMq implements RocketMQListener<MessageExt> {
    @Override
    public void onMessage(MessageExt messageExt) {
        int times = messageExt.getReconsumeTimes();
         System.out.println("重试次数："+times);
        System.out.println("接收到了消息1:" + new String(messageExt.getBody()));
        handleDb();
    }
    private void handleDb() {
        int a  = 1/0;
    }
}
